/*** Eclipse Class Decompiler plugin, copyright (c) 2012 Chao Chen (cnfree2000@hotmail.com) ***/
package com.qihoo.gamecenter.sdk.suspend.floatwindow.floattingicon;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Rect;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.text.TextUtils;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.view.animation.AnimationSet;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.OvershootInterpolator;
import android.view.animation.TranslateAnimation;
import android.widget.FrameLayout.LayoutParams;
import android.widget.ImageView;
import android.widget.LinearLayout.LayoutParams;
import android.widget.TextView;

public class e {
    private Context a;
    private View b;
    private ImageView c;
    private TextView d;
    private c e;
    private c.a f;
    private boolean g = false;
    private int h = 0;
    private int i = 0;
    private Rect j = new Rect();

    public void a(Context paramContext, View paramView, c.a parama, c paramc) {
        if ((paramContext == null) || (parama == null) || (paramView == null))
            return;
        this.a = paramContext;
        this.e = paramc;
        this.f = parama;
        this.b = paramView;
        this.c = ((ImageView) this.b.findViewById(com.qihoo.gamecenter.sdk.suspend.d.b.o));
        this.d = ((TextView) this.b.findViewById(com.qihoo.gamecenter.sdk.suspend.d.b.p));
        Object localObject = null;
        if (parama.f) {
            localObject = com.qihoo.gamecenter.sdk.common.b.a.a(this.a, "360sdk_res/res6.dat", 67108872);
        }
        else {
            Bitmap localBitmap;
            if ((TextUtils.isEmpty(parama.c))
                    || ((localBitmap = com.qihoo.gamecenter.sdk.suspend.a.a.a.a().a(parama.c)) == null))
                localObject = com.qihoo.gamecenter.sdk.common.b.a.a(this.a, "360sdk_res/res6.dat", 67108870);
            else
                localObject = new BitmapDrawable(localBitmap);
        }
        if (localObject != null)
            this.c.setImageDrawable((Drawable) localObject);
        if (!(TextUtils.isEmpty(this.f.d)))
            this.d.setText(this.f.d);
        this.b.setOnClickListener(new View.OnClickListener() {
            public void onClick(View paramView) {
                if (e.a(e.this) == null)
                    return;
                e.a(e.this).a(e.b(e.this));
            }
        });
    }

    public Rect a() {
        return this.j;
    }

    public void a(Rect paramRect) {
        if ((paramRect == null) || (this.j == null))
            return;
        this.j.left = paramRect.left;
        this.j.right = paramRect.right;
        this.j.top = paramRect.top;
        this.j.bottom = paramRect.bottom;
    }

    public void b() {
        if ((this.b == null) || (this.j == null))
            return;
        this.j.left = 0;
        this.j.right = 0;
        this.j.top = 0;
        this.j.bottom = 0;
        this.b.setVisibility(8);
    }

    public void a(int paramInt) {
        if (this.b == null)
            return;
        this.b.clearAnimation();
        this.b.setVisibility(paramInt);
    }

    public int c() {
        if (this.b == null)
            return 8;
        return this.b.getVisibility();
    }

    public void a(Rect paramRect, int paramInt) {
        if ((this.b == null) || (paramRect == null) || (this.j == null) || (paramRect.width() <= 0)
                || (paramRect.height() <= 0))
            return;
        this.h = paramInt;
        b(paramRect);
    }

    public void b(Rect paramRect, int paramInt) {
        if ((this.b == null) || (paramRect == null) || (this.j == null) || (paramRect.width() <= 0)
                || (paramRect.height() <= 0))
            return;
        this.h = paramInt;
        b(paramRect);
        g();
    }

    public void c(Rect paramRect, int paramInt) {
        if ((this.b == null) || (paramRect == null) || (this.j == null) || (paramRect.width() <= 0)
                || (paramRect.height() <= 0))
            return;
        this.i = paramInt;
        b(paramRect);
    }

    public void d(Rect paramRect, int paramInt) {
        if ((this.b == null) || (paramRect == null) || (this.j == null) || (paramRect.width() <= 0)
                || (paramRect.height() <= 0))
            return;
        this.i = paramInt;
        b(paramRect);
        h();
    }

    private void b(Rect paramRect) {
        if ((this.b == null) || (paramRect == null) || (this.j == null) || (paramRect.width() <= 0)
                || (paramRect.height() <= 0))
            return;
        this.j.left = paramRect.left;
        this.j.right = paramRect.right;
        this.j.top = paramRect.top;
        this.j.bottom = paramRect.bottom;
        FrameLayout.LayoutParams localLayoutParams = new FrameLayout.LayoutParams(this.j.width(), this.j.height(), 51);
        localLayoutParams.leftMargin = this.j.left;
        this.b.setLayoutParams(localLayoutParams);
        int k = d.d(this.a);
        LinearLayout.LayoutParams localLayoutParams1 = new LinearLayout.LayoutParams(k, k, 49.0F);
        localLayoutParams1.topMargin = d.e(this.a);
        this.c.setLayoutParams(localLayoutParams1);
    }

    private void g() {
        int k = this.h - this.j.left;
        b(k);
    }

    private void h() {
        b(this.i);
    }

    private void b(int paramInt) {
        if (this.b == null)
            return;
        this.b.clearAnimation();
        com.qihoo.gamecenter.sdk.suspend.b.b
                .a("MenuItemView", "mAniLeftOffset=" + this.h + " xOffset=" + paramInt + " left=" + this.j.left
                        + " right=" + this.j.right + " top=" + this.j.top + " bottom=" + this.j.bottom);
        AlphaAnimation localAlphaAnimation = new AlphaAnimation(0.0F, 1.0F);
        localAlphaAnimation.setDuration(500L);
        TranslateAnimation localTranslateAnimation = new TranslateAnimation(paramInt, 0.0F, 0.0F, 0.0F);
        localTranslateAnimation.setInterpolator(new OvershootInterpolator());
        localTranslateAnimation.setDuration(500L);
        AnimationSet localAnimationSet = new AnimationSet(false);
        localAnimationSet.addAnimation(localAlphaAnimation);
        localAnimationSet.addAnimation(localTranslateAnimation);
        localAnimationSet.setFillAfter(true);
        this.b.setVisibility(0);
        this.b.startAnimation(localAnimationSet);
    }

    public boolean d() {
        if (this.b == null)
            return true;
        return (this.b.getVisibility() != 0);
    }

    public void e() {
        c(this.i);
    }

    public void f() {
        int k = this.h - this.j.left;
        c(k);
    }

    private void c(int paramInt) {
        if ((this.b == null) || (this.b.getVisibility() != 0) || (this.g))
            return;
        this.g = true;
        this.b.clearAnimation();
        com.qihoo.gamecenter.sdk.suspend.b.b
                .a("MenuItemView", "mAniLeftOffset=" + this.h + " xOffset=" + paramInt + " left=" + this.j.left
                        + " right=" + this.j.right + " top=" + this.j.top + " bottom=" + this.j.bottom);
        AlphaAnimation localAlphaAnimation = new AlphaAnimation(1.0F, 0.0F);
        localAlphaAnimation.setDuration(300L);
        TranslateAnimation localTranslateAnimation = new TranslateAnimation(0.0F, paramInt, 0.0F, 0.0F);
        localTranslateAnimation.setInterpolator(new DecelerateInterpolator());
        localTranslateAnimation.setDuration(300L);
        AnimationSet localAnimationSet = new AnimationSet(false);
        localAnimationSet.addAnimation(localAlphaAnimation);
        localAnimationSet.addAnimation(localTranslateAnimation);
        localAnimationSet.setAnimationListener(new Animation.AnimationListener() {
            public void onAnimationStart(Animation paramAnimation) {}

            public void onAnimationRepeat(Animation paramAnimation) {}

            public void onAnimationEnd(Animation paramAnimation) {
                e.c(e.this).setVisibility(8);
                e.a(e.this, false);
            }
        });
        this.b.setVisibility(0);
        this.b.startAnimation(localAnimationSet);
    }
}